import {BrowserModule} from '@angular/platform-browser';
import {InjectionToken, NgModule} from '@angular/core';

import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from '@angular/common/http';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {registerLocaleData} from '@angular/common';
import zh from '@angular/common/locales/zh';
import {RegisterComponent} from './components/register/register.component';
import {LoginComponent} from './components/login/login.component';
import {ChangePasswordComponent} from './components/change-password/change-password.component';
import {HomeComponent} from './components/home/home.component';
import {SplashComponent} from './components/splash/splash.component';
import {UserComponent} from './components/user/user.component';
import {NgxElectronModule} from 'ngx-electron';
import {serverConfigFactory, ServerConfigService} from './api/server-config.service';
import {TokenInterceptorService} from './service/interceptor/token-interceptor.service';
import {AppService} from './service/app/app.service';
import {LinesComponent} from './components/lines/lines.component';
import {SendEmailComponent} from './components/send-email/send-email.component';
import {RestPasswordComponent} from './components/rest-password/rest-password.component';
import {ChargeComponent} from './components/charge/charge.component';
import {AppProxyComponent} from './components/app-proxy/app-proxy.component';
import {RouterModeComponent} from './components/router-mode/router-mode.component';
import { BuyTimeComponent } from './components/buy-time/buy-time.component';
import { SwiperInstanceComponent } from './components/swiper-instance/swiper-instance.component';

registerLocaleData(zh);

export const configFilePath = new InjectionToken('config file', {factory: () => 'config.json'});


const serverConfigProvider = {
  provide: ServerConfigService,
  useFactory: serverConfigFactory,
  deps: [HttpClient, configFilePath]
};

@NgModule({
  declarations: [
    AppComponent,
    RegisterComponent,
    LoginComponent,
    ChangePasswordComponent,
    HomeComponent,
    SplashComponent,
    UserComponent,
    LinesComponent,
    SendEmailComponent,
    RestPasswordComponent,
    ChargeComponent,
    AppProxyComponent,
    RouterModeComponent,
    BuyTimeComponent,
    SwiperInstanceComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgZorroAntdModule,
    FormsModule,
    ReactiveFormsModule,
    NgxElectronModule,
    HttpClientModule,
    BrowserAnimationsModule,
  ],
  providers: [
    HttpClient,
    serverConfigProvider,
    AppService,
    {provide: NZ_I18N, useValue: zh_CN},
    {provide: HTTP_INTERCEPTORS, useClass: TokenInterceptorService, multi: true},
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}
